home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!sun-barr!ames!pasteur!nntp
- From: scott.oaks@East.Sun.COM (Scott Oaks)
- Newsgroups: comp.sources.x
- Subject: v15i163: OpenLook Virtual Window Mgr (3.0), Part17/21
- Message-ID: <1992Feb4.135956.8094@pasteur.Berkeley.EDU>
- Date: 4 Feb 92 13:59:56 GMT
- References: <csx-15i147-olvwm-3.0@uunet.UU.NET>
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: University of California, at Berkeley
- Lines: 1936
- Approved: dcmartin@msi.com
- Nntp-Posting-Host: postgres.berkeley.edu
-
- Submitted-by: scott.oaks@East.Sun.COM (Scott Oaks)
- Posting-number: Volume 15, Issue 163
- Archive-name: olvwm-3.0/part17
-
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 17 (of 21)."
- # Contents: CHANGES environ.c win.c win.h winbutton.c
- # Wrapped by dcmartin@fascet on Tue Jan 14 05:54:47 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'CHANGES' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'CHANGES'\"
- else
- echo shar: Extracting \"'CHANGES'\" \(10406 characters\)
- sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
- Xolvwm 3.0 notes:
- X
- XINCOMPATIBILITIES WITH VERSION 2:
- X1) The Shift-Arrow and Control-Arrow methods of moving in the desktop have
- X had their functionality reversed: shift-arrow now moves by half-desktops
- X and control arrow now moves by many desktops. This is for consistency
- X with the new mouseless commands which interpret ctrl-arrow as move ten
- X items.
- X
- X2) Double clicking anywhere within the VDM now moves to that location rather
- X than zooming a window which may have been clicked on. This is either
- X a bug fix or a new feature, depending on your perspective.
- X
- X3) Pinned Root menus are by default no longer sticky; they must be stuck
- X via the sticky list in .Xdefaults
- X
- XNEW FEATURES IN VERSION 3:
- X
- XMost of the changes in this version of olvwm are inherited from changes
- Xmade to the 3.0 olwm and are not listed here. See the olwm man page for
- Xdetails.
- X
- X MENU CHANGES:
- X
- X 1) There is a new menu token WINMENU. Specifying this token
- X creates an entry in your root menu containing a pull-right
- X menu; the pull-right menu is a menu containing the titles of all
- X active windows on the desktop (windows which are iconic will be
- X listed with a preceeding graphic symbol). Selecting a window
- X from this list will cause a user-specifiable action. These
- X actions may be specified in the .olvwmrc file (see below); in
- X the absence of any specifications, the default action will be to
- X warp to the location on the desktop where the selected window is
- X located, to open that window if it is iconic, and to raise that
- X window to the top of the stacking order.
- X
- X 2) There is a new menu token DIRMENU. Specifying this token
- X creates an entry containing a pull-right menu; the pull-right
- X menu is a menu containing every file in the given directory.
- X Selecting an entry off this menu (attempts to) execute the
- X given file.
- X
- X 3) There is a new menu token STICK_UNSTICK_SELN which works to
- X toggle the stickyness of the selected clients.
- X
- X 4) There is a new menu token COLUMNS which specifies how many columns
- X a menu should have. It must appear after the start but before the
- X end of a menu, e.g.
- X
- X"Shells" MENU
- X"Shells" COLUMNS 2
- X "Shelltool..." exec shelltool
- X ...
- X"Shells" END
- X
- X 5) You can now specify an X bitmap file instead of a name for a menu
- X item; enclose the bitmap file in <>:
- X
- X</usr/openwin/include/X11/bitmaps/xfd_icon> exec xfd -fn lucidasans
- X
- X NEW RESOURCES:
- X
- X 1) ResizeMoveGeometry: controls the placement of the olwm 3.0
- X moveresize feedback box. It's a standard X Geometry string,
- X but you may specify the string center if you want it centered
- X regardless of display resolution.
- X
- X 2) UseImages: If UseImages is set to UseNone, you'll get what you
- X always got. If it's set to UseVDM, you'll get a bitmap-based
- X VDM menu (this is the default). If it's set to UseAll you'll get
- X bitmap-based window menus.
- X
- X 3) FullSizeZoomX: When this attribute is set to True, selecting
- X "Full Size" from the window menu will cause the window to zoom
- X horizontally as well as vertically.
- X
- X 4) InputFocusColor: When this attribute is set to a color
- X specification, then the frame which has the Input Focus will be
- X drawn in that color, as will the virtual window representing that
- X frame.
- X
- X 5) NoDecor: This is a list attribute, similar to MinimalDecor.
- X Windows whose Name, Instance, or Class match an entry in this list
- X will be ignored by the window manager; though they will have a
- X corresponding virtual window drawn in the VDM, they will be sticky
- X or non-sticky depending on the appropriate entry in the
- X VirtualSticky list, and they will be affected by the new Window
- X Menu and Warp options described below. This is unlike windows
- X which have the override_redirect flag set, for which absolutely
- X no window manager actions have any effect.
- X
- X 6) VirtualMoveGroups: If this is True (default), then whenever you
- X move a window from one logical screen to another, all of the
- X window's followers (popups, menus, and icon) will follow it.
- X Setting this to false gives the olvwm 2.0 behaviour where only
- X the selected window moved.
- X
- X 7) RaiseOnMove: If this is True, then whenever a window is moved
- X it will be raised to the top of the stacking order. This helps
- X to avoid windows getting lost when dragging them out of the VDM
- X (but the default is false).
- X
- X 8) VirtualRaiseVDM: If this is True, the VDM will always appear on
- X the top of the stacking order.
- X
- X NEW RC FILE CHANGES:
- X olvwm now reads an rc file to control usage in three areas: hot keys
- X (desktop actions when a certain key is pressed), screen bindings
- X (always map certain applications to specified logical screens), and
- X WINMENU actions. See the olvwmrc.man page for details.
- X
- X MISC FUNCTIONAL CHANGES:
- X
- X 1) Popups will always appear on the same screen as their leader, even
- X if that screen isn't visible.
- X
- X 2) You can now drop something into a virtual window.
- X
- X 3) The keymappings for the VDM can all be set via resources; see the
- X man page for details.
- X
- X 4) There is a new VDM icon.
- X
- XBUGS FIXED IN VERSION 3
- X
- X1) Switching between screens will correctly set the arrow-key input focus.
- X
- X2) Menus which are taller than the screen are now split into columns; menu
- X titles are centered
- X
- X3) Sticky windows now always map to the current screen.
- X
- X4) Several off-by-one grid errors have been fixed.
- X
- X5) Changes to a tool's title are now reflected immediately in the VDM.
- X
- X6) Override_redirect windows can no longer be affected by the L keys.
- X
- X7) Exiting olvwm and starting another wm now correctly positions the windows
- X
- X8) Miscellaneous fixes in the documentation
- X
- X---Changes in Version 2.2----------------------------------------
- XFUNCTIONAL CHANGES:
- X
- X1) New ways to move the desktop, including:
- X A) If a motion key is shifted, motion amount is doubled
- X B) If a motion key is pressed with the CTRL key, motion amount is halved
- X C) If a motion key is pressed with SHIFT/CTRL, motion amount is multiplied
- X by 20, which should take it to the nearest edge
- X D) The function keys 1-10 can be used to move to a specific screen:
- X screens are number across and then down from 1 to 10.
- X E) If a motion key is pressed with the META key, then it will work no
- X matter where the keyboard focus is.
- X F) The MENU button within the VDM brings up a (pinnable) menu allowing
- X motions.
- X
- X2) Virtual Windows now react to mouse events and Front/Open keystrokes like
- X any other window; they can be grouped, their frame menu displayed, etc.
- X
- X3) New RelativePosition attribute added
- X
- X In past versions, by default, when the user specified a window
- X placement, that position was used in absolute co-ordinates, and
- X when a program specified a window placement, that position was
- X used in relative co-ordinates.
- X
- X Some programs (frame and mailtool, for example) save some window
- X states somewhere (frame does it in the document, mailtool in
- X the .mailtool-init file) and then brings up these windows with
- X user-specified co-ordinates. This means that if you start these
- X programs in another part of the Virtual Desktop, some frames will
- X come up in the wrong area of the screen -- they will come up
- X where they last were rather than where you are now.
- X
- X Setting the RelativePosition attribute to True (its default) will
- X make all window placement strings be relative to the current
- X screen.
- X
- X The only time this setting should be a problem is if you are
- X any place other than the upper-left corner and you want to bring
- X up a window in absolute co-ordinates. But since absolute
- X co-ordinates are normally only useful for things brought up in
- X your .xinitrc/.openwin-init file, that shouldn't normally be
- X a problem.
- X
- X4) You can now specify sticky applications by the first word in their
- X WM_NAME attribute as well as their WM_CLASS/WM_INSTANCE attribute.
- X For some tools (eg Mailtool), the WM_NAME is multi-word:
- X Mail Tool - /var/spool/mail/sdo for example; use only the first
- X word (Mail) in the list as xrdb is incapable of imbedding spaces
- X in the list.
- X
- X This allows (most) XView applications and pinned menus to be sticky.
- X Note that the XView clock has by default no WM_NAME either; but
- X it (and all XView applications) can set their name on the command
- X line with -Wl <name>.
- X
- X5) The VDM now displays a grid (by default, but it can be turned off by
- X setting VirtualGrid to None) for screen sizes. When the grid
- X is on, dragging the mouse to move the desktop is constrained to move
- X between whole screen regions (unless the CTRL button is pressed
- X while dragging the mouse, in which case arbitrary positioning of
- X the desktop is enabled). If the grid is off, you can move the desktop
- X by arbitrary amounts unless the CTRL button is pressed, in which case
- X movement will be constrained to full screens.
- X
- XBUG FIXES
- X
- X6) Windows which don't register with the Window manager and are raised
- X by the "Front" key no longer core dump.
- X
- X7) The Save Workspace command now correctly saves non-Xview applications.
- X
- X8) When olvwm is in MinimalDecor, it will resize correctly.
- X
- X9) Clients like xterm can now receive input focus if click-to-type is in
- X effect and the inside of the window is clicked.
- X
- X10) Icons can now be moved into the VDM when SnapToGrid is in effect.
- X
- X11) Applications which start sticky can be unstuck.
- X
- X12) Moving multiple windows into the VDM no longer collapses the windows
- X onto each other.
- X
- X13) The root now correctly inherits keyboard events when shells exit.
- X
- X14) Menus can now have embedded environmental variables
- X
- X15) Sub-frames now inherit the stickyness of their parent. Note that in
- X the OPEN LOOK paradigm, this means that command frames and pinned
- X menus will inherit the stickyness of their parent but any other
- X base frames (e.g. the compose window from mailtool) will not.
- X
- X16) olvwm now avoids the OW2.0 server bug for small windows on CG3 displays
- X which used to cause the server to crash.
- X
- X17) Windows can no longer be dropped into obscured portions of the VDM
- X
- XSOURCE FIXES
- X
- X18) Imakefile now lists resources1.o
- X [Okay, I said I was no Imake user . . .]
- X
- X19) Imakefile no longer tries to install openwin-menu
- X
- X20) Imakefile correctly installs man page
- X
- X21) New Imakefile for those without MIT XView but with OpenWindows
- END_OF_FILE
- if test 10406 -ne `wc -c <'CHANGES'`; then
- echo shar: \"'CHANGES'\" unpacked with wrong size!
- fi
- # end of 'CHANGES'
- fi
- if test -f 'environ.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'environ.c'\"
- else
- echo shar: Extracting \"'environ.c'\" \(4582 characters\)
- sed "s/^X//" >'environ.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989, 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)environ.c 1.6 91/09/14 SMI"
- X
- X#include <stdio.h>
- X#ifdef SYSV
- X#include <string.h>
- X#else
- X#include <strings.h>
- Xextern char *strrchr();
- Xextern char *strchr();
- X#endif
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xatom.h>
- X#include "mem.h"
- X
- Xextern char **environ;
- X
- X/* -----------------------------------------------------------------------
- X * Local Data Structures
- X * -----------------------------------------------------------------------*/
- X
- X/*
- X * Env - environment object
- X */
- Xtypedef struct _env {
- X char **environ; /* array of environment strings */
- X int length; /* length of environ array */
- X int used; /* number of entries actually used */
- X} Env;
- X
- X/* -----------------------------------------------------------------------
- X * Local Functions
- X * -----------------------------------------------------------------------*/
- X
- X/*
- X * createEnv - Creates a new environment array that is the length of
- X * of the current environment plus the number of additions.
- X */
- Xstatic void
- XcreateEnv(env,nadditions)
- X Env *env;
- X int nadditions;
- X{
- X int i = 0;
- X
- X /* find the number of items in the current environ */
- X while (environ[i] != (char *)NULL) {
- X i++;
- X }
- X
- X /* create space for the environ strings */
- X env->used = i;
- X env->length = env->used + nadditions + 1;
- X env->environ = MemAlloc(env->length*sizeof(char *));
- X
- X /* copy the current environ into the new one */
- X for (i=0; i<env->used; i++) {
- X env->environ[i] = MemNewString(environ[i]);
- X }
- X env->environ[i] = (char *)NULL;
- X}
- X
- X/*
- X * putEnv - Puts the name,value pair into the specified environment
- X * replacing any existing values.
- X * Assumes there is space for the new setting.
- X */
- Xstatic void
- XputEnv(env,name,value)
- X Env *env;
- X char *name;
- X char *value;
- X{
- X int nameLen = strlen(name);
- X char *envVar;
- X int count;
- X
- X /* create new env string with space for '=' and null */
- X envVar = (char *)MemAlloc(nameLen + strlen(value) +2);
- X
- X (void)sprintf(envVar,"%s=%s",name,value);
- X
- X /* search through, checking for variable in question */
- X for (count=0 ; count<env->used; count++) {
- X if (!strncmp(env->environ[count],name,nameLen))
- X break;
- X }
- X
- X
- X if (count == env->used) /* finished loop without match */
- X env->used++; /* added 1 more var to the env */
- X else
- X MemFree(env->environ[count]); /* don't need */
- X
- X env->environ[count] = envVar;
- X
- X /* make sure the last entry in the vector is NULL */
- X env->environ[env->used] = (char *)NULL;
- X
- X}
- X
- X/*
- X * putDisplayEnv - sets the DISPLAY env to the appropriate screen
- X */
- Xstatic void
- XputDisplayEnv(env,dpy,screen)
- X Env *env;
- X Display *dpy;
- X int screen;
- X{
- X char *display = DisplayString(dpy);
- X char *colon,*dot;
- X char value[128];
- X int len;
- X
- X if ((colon = strrchr(display,':')) == (char *)NULL) {
- X return;
- X }
- X if ((dot = strchr(colon,'.')) != (char *)NULL) {
- X len = dot - display;
- X } else {
- X len = colon - display;
- X }
- X
- X (void)sprintf(value,"%.*s.%d",len,display,screen);
- X
- X putEnv(env,"DISPLAY",value);
- X}
- X
- X#ifndef NOSVENV
- X/*
- X * putSunViewEnv - sets the various SV environment variables
- X */
- Xstatic void
- XputSunViewEnv(env,dpy,screen)
- X Env *env;
- X Display *dpy;
- X int screen;
- X{
- X static char *svEnv[] = { "WINDOW_PARENT",
- X "WMGR_ENV_PLACEHOLDER",
- X "WINDOW_TTYPARMS" };
- X int i, svEnvLen = sizeof(svEnv)/sizeof(char *);
- X char *result,*curpos;
- X unsigned long nitems,remainder;
- X extern void *GetWindowProperty();
- X extern Atom AtomSunViewEnv;
- X
- X result = (char *)GetWindowProperty(dpy,RootWindow(dpy,screen),
- X AtomSunViewEnv,0L,100000L,
- X XA_STRING,8,&nitems,&remainder);
- X
- X if (result == NULL)
- X return;
- X
- X curpos = result;
- X for (i=0; i<svEnvLen; i++) {
- X putEnv(env,svEnv[i],curpos);
- X curpos += strlen(curpos) + 1;
- X }
- X
- X}
- X#endif /* NOSVENV */
- X
- X/* -----------------------------------------------------------------------
- X * Global Functions
- X * -----------------------------------------------------------------------*/
- X
- X/*
- X * MakeEnviron - returns a new environment array that contains the
- X * current environ plus a modified DISPLAY and
- X * SunView environment variables.
- X */
- Xchar **
- XMakeEnviron(dpy,screen)
- X Display *dpy;
- X int screen;
- X{
- X Env newEnv;
- X int nadditions;
- X
- X nadditions = 1; /* for DISPLAY */
- X
- X#ifndef NOSVENV
- X nadditions += 3; /* for SV environment */
- X#endif /* NOSVENV */
- X
- X createEnv(&newEnv,nadditions);
- X
- X putDisplayEnv(&newEnv,dpy,screen);
- X
- X#ifndef NOSVENV
- X putSunViewEnv(&newEnv,dpy,screen);
- X#endif /* NOSVENV */
- X
- X return newEnv.environ;
- X}
- END_OF_FILE
- if test 4582 -ne `wc -c <'environ.c'`; then
- echo shar: \"'environ.c'\" unpacked with wrong size!
- fi
- # end of 'environ.c'
- fi
- if test -f 'win.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'win.c'\"
- else
- echo shar: Extracting \"'win.c'\" \(10853 characters\)
- sed "s/^X//" >'win.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)win.c 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)win.c 26.12 91/09/14 SMI"
- X *
- X */
- X
- X#include <stdio.h>
- X#include <memory.h>
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include <X11/Xatom.h>
- X
- X#include "i18n.h"
- X#include "olwm.h"
- X#include "win.h"
- X#include "mem.h"
- X#include "st.h"
- X#include "notice.h"
- X
- X/***************************************************************************
- X* local functions
- X***************************************************************************/
- X
- X/*ARGSUSED*/
- Xstatic enum st_retval
- XdoRedrawOneWindow(w,win,c)
- XWindow w;
- XWinGeneric *win;
- Xvoid *c;
- X{
- X if ((WinFunc(win,core.drawfunc) != NULL) && (win->core.client != NULL))
- X (WinFunc(win,core.drawfunc))(win->core.client->dpy,win);
- X return ST_CONTINUE;
- X}
- X
- Xstatic void
- XcallSelectTree(dpy,win,sel)
- XDisplay *dpy;
- XWinGeneric *win;
- XBool sel;
- X{
- X List *l = win->core.children;
- X
- X if (WinFunc(win,core.selectfunc) != NULL) {
- X (*(WinFunc(win,core.selectfunc)))(dpy,win,sel);
- X VirtualSelect(win, sel);
- X }
- X for (win = ListEnum(&l); win != NULL; win = ListEnum(&l))
- X callSelectTree(dpy, win, sel);
- X}
- X
- X/* Destroying a window tree: walk the trees associated with a client,
- X * invoking the destroyfuncs on each. The order that the windows are
- X * destroyed is significant; it works from the root upwards. The
- X * client structure is not affected; it is assumed that this function
- X * is only called from routines which take responsibility for removing
- X * the client structure as well.
- X */
- Xstatic void
- XcallDestroyTree(dpy,win)
- XDisplay *dpy;
- XWinGeneric *win;
- X{
- X List *l;
- X WinGeneric *cwin;
- X
- X if (win == NULL)
- X return;
- X l = win->core.children;
- X for (cwin = ListEnum(&l); cwin != NULL; cwin = ListEnum(&l))
- X callDestroyTree(dpy, cwin);
- X if (WinFunc(win,core.destroyfunc) != NULL)
- X (*(WinFunc(win,core.destroyfunc)))(dpy,win);
- X}
- X
- Xstatic void
- XsetTreeConfig(dpy,win)
- XDisplay *dpy;
- XWinGeneric *win;
- X{
- X List *l = win->core.children;
- X WinGeneric *wc;
- X
- X (*(WinFunc(win,core.setconfigfunc)))(dpy,win);
- X for (wc = ListEnum(&l); wc != NULL; wc = ListEnum(&l))
- X {
- X setTreeConfig(dpy,wc);
- X }
- X}
- X
- Xstatic void
- XcallFocusTree(win, focus)
- XWinGeneric *win;
- XBool focus;
- X{
- X List *l;
- X WinGeneric *cwin;
- X
- X if (win == NULL)
- X return;
- X if (WinFunc(win,core.focusfunc) != NULL) {
- X (WinFunc(win,core.focusfunc))(win->core.client->dpy,win,focus);
- X }
- X l = win->core.children;
- X for (cwin = ListEnum(&l); cwin != NULL; cwin = ListEnum(&l))
- X callFocusTree(cwin, focus);
- X}
- X
- X
- Xstatic void
- XcallDrawTree(win)
- X WinGeneric *win;
- X{
- X List *l;
- X WinGeneric *cwin;
- X
- X if (WinFunc(win,core.drawfunc) != NULL)
- X (WinFunc(win,core.drawfunc))(win->core.client->dpy,win);
- X
- X l = win->core.children;
- X for (cwin = ListEnum(&l); cwin != NULL; cwin = ListEnum(&l))
- X callDrawTree(cwin);
- X}
- X
- X
- X/***************************************************************************
- X* global functions
- X***************************************************************************/
- X
- X/* WinCallSelect - call a client's select functions for either the icon or
- X * frame trees, depending on which is visible. Passes along sel,
- X * which is True iff the client is being selected.
- X */
- Xvoid
- XWinCallSelect(cli, sel)
- XClient *cli;
- XBool sel;
- X{
- X if (cli->wmState == NormalState)
- X callSelectTree(cli->dpy, cli->framewin, sel);
- X else if (cli->wmState == IconicState)
- X callSelectTree(cli->dpy, cli->iconwin, sel);
- X}
- X
- X/* WinCallFocus - call a client's focus functions for the frame tree.
- X * Passes along focus, which is True iff the client is gaining focus
- X */
- Xvoid
- XWinCallFocus(win,focus)
- XWinGeneric *win;
- XBool focus;
- X{
- X if (win == NULL)
- X return;
- X win->core.client->isFocus = focus;
- X callFocusTree(win, focus);
- X VirtualChangeFocus(win, focus);
- X}
- X
- X/* WinCallDestroy - call a client's destroy functions for both the icon and
- X * frame trees
- X */
- Xvoid
- XWinCallDestroy(cli)
- XClient *cli;
- X{
- X Display *dpy = cli->dpy;
- X WinPaneFrame *framewin = cli->framewin;
- X WinIconFrame *iconwin = cli->iconwin;
- X
- X callDestroyTree(dpy, framewin);
- X callDestroyTree(dpy, iconwin);
- X}
- X
- X/* WinCallConfig - initiate a configuration change, starting at some
- X * particular window.
- X * Configuration change works as follows: a window is the initiator
- X * of the change. If the children of this window need to be sized,
- X * then they are called to do so; then the window sizes itself and
- X * sets the position of each of its children. This process is
- X * repeated on the parent of the initiating window, and so on up
- X * to the top window in the hierarchy (presumably a frame).
- X * A second pass then occurs, doing a depth-first preorder
- X * traversal of the window tree, performing the window's set
- X * configuration function to make the computed change.
- X * In the first pass, any window which changes its configuration
- X * should return this fact to be propagated back to this routine;
- X * if no window has changed configuration then the second pass
- X * won't be performed.
- X * The initiator window is passed (in some cases) the configure
- X * request event which cause the action to begin.
- X */
- Xvoid
- XWinCallConfig(dpy,win,pxcre)
- XDisplay *dpy;
- XWinGeneric *win;
- XXConfigureRequestEvent *pxcre;
- X{
- X Bool fDirty = False;
- X WinGeneric *w;
- X
- X do
- X {
- X fDirty = (WinFunc(win,core.newconfigfunc))(win,pxcre) || fDirty;
- X pxcre = NULL;
- X w = win;
- X }
- X while ((win = win->core.parent) != NULL);
- X if (fDirty)
- X {
- X setTreeConfig(dpy,w);
- X }
- X}
- X
- X/*
- X * WinCallDraw
- X * Call all child windows' draw functions.
- X */
- Xvoid
- XWinCallDraw(win)
- X WinGeneric *win;
- X{
- X callDrawTree(win);
- X}
- X
- X
- X/* WinAddChild -- add a child to a parent's list of children
- X */
- Xvoid
- XWinAddChild(parent,child)
- XWinGeneric *parent;
- XWinGeneric *child;
- X{
- X parent->core.children = ListCons(child,parent->core.children);
- X child->core.parent = parent;
- X}
- X
- X/* WinRemoveChild -- remove a child from a parent's list of children
- X */
- Xvoid
- XWinRemoveChild(parent,child)
- XWinGeneric *parent;
- XWinGeneric *child;
- X{
- X List **l;
- X
- X for (l = &(parent->core.children); *l != NULL; l = &((*l)->next))
- X {
- X if ((WinGeneric *)((*l)->value) == child)
- X {
- X ListDestroyCell(l);
- X return;
- X }
- X }
- X#ifdef DEBUG
- X printf("Warning: tried to remove child %x from parent %x, but it wasn't there\n",child,parent);
- X#endif
- X}
- X
- X/* WinRootPos -- figure the root coordinates of a window's position
- X */
- Xvoid
- XWinRootPos(win,px,py)
- XWinGeneric *win;
- Xint *px, *py;
- X{
- X *px = 0;
- X *py = 0;
- X for ( ; win != NULL; win = win->core.parent)
- X {
- X *px += win->core.x;
- X *py += win->core.y;
- X }
- X}
- X
- X
- X/* WinRedrawAllWindows -- call every window's draw function (if provided)
- X */
- Xvoid
- XWinRedrawAllWindows()
- X{
- X WIApply(doRedrawOneWindow, NULL);
- X}
- X
- X/* WinShowHelp -- show help for that window if available
- X */
- XBool
- XWinShowHelp(dpy,win,mousex,mousey)
- XDisplay *dpy;
- XWinGeneric *win;
- Xint mousex,mousey;
- X{
- X int screen;
- X char *buttons[1];
- X char *msg;
- X NoticeBox noticeBox;
- X
- X if (win->core.helpstring) {
- X if (win->core.client)
- X screen = win->core.client->screen;
- X else
- X screen = DefaultScreen(dpy);
- X
- X if (!ShowHelpWindow(screen,mousex,mousey,
- X win->core.helpstring)) {
- X
- X buttons[0] = gettext("Ok");
- X msg =
- X gettext("Couldn't write to olwmslave\nNo Help Available for olwm");
- X
- X noticeBox.numButtons = NOTICE_BUTTON_COUNT(buttons);
- X noticeBox.defaultButton = 0;
- X noticeBox.buttonText = buttons;
- X noticeBox.msgText = msg;
- X noticeBox.boxX = -1; /* centered */
- X noticeBox.boxY = -1;
- X (void)UseNoticeBox(dpy,screen,¬iceBox);
- X return False;
- X }
- X return True;
- X }
- X return False;
- X}
- X
- X/***************************************************************************
- X* general event/class functions
- X***************************************************************************/
- X
- Xint
- XWinDrawFunc(win)
- XWinGeneric *win;
- X{
- X if ((WinFunc(win,core.drawfunc) != NULL) && (win->core.client != NULL))
- X (WinFunc(win,core.drawfunc))(win->core.client->dpy,win);
- X}
- X
- Xint
- XWinEventExpose(dpy, event, win)
- XDisplay *dpy;
- XXEvent *event;
- XWinGeneric *win;
- X{
- X if (event->xexpose.count == 0)
- X (WinFunc(win,core.drawfunc))(dpy, win);
- X}
- X
- X
- Xint
- XWinNewPosFunc(win,x,y)
- XWinGeneric *win;
- Xint x,y;
- X{
- X if (x != win->core.x)
- X {
- X win->core.x = x;
- X win->core.dirtyconfig |= CWX;
- X }
- X
- X if (y != win->core.y)
- X {
- X win->core.y = y;
- X win->core.dirtyconfig |= CWY;
- X }
- X
- X return win->core.dirtyconfig;
- X}
- X
- X
- Xint
- XWinNewConfigFunc(win, pxcre)
- XWinGeneric *win;
- XXConfigureRequestEvent *pxcre;
- X{
- X int neww = WinFunc(win,core.widthfunc)(win, pxcre);
- X int newh = WinFunc(win,core.heightfunc)(win, pxcre);
- X
- X if (neww != win->core.width)
- X {
- X win->core.width = neww;
- X win->core.dirtyconfig |= CWWidth;
- X }
- X if (newh != win->core.height)
- X {
- X win->core.height = newh;
- X win->core.dirtyconfig |= CWHeight;
- X }
- X return win->core.dirtyconfig;
- X}
- X
- X
- Xint
- XWinSetConfigFunc(dpy, win)
- XDisplay *dpy;
- XWinGeneric *win;
- X{
- X XWindowChanges xwc;
- X int dw = DisplayWidth(win->core.client->dpy,
- X win->core.client->screen);
- X int dh = DisplayHeight(win->core.client->dpy,
- X win->core.client->screen);
- X
- X if (win->core.dirtyconfig)
- X {
- X if (win->core.client->sticky) {
- X if (win->core.x + win->core.width < 0) {
- X win->core.x = dw + (win->core.x % dw);
- X win->core.dirtyconfig |= CWX;
- X }
- X else if (win->core.x >= dw) {
- X win->core.x = win->core.x % dw;
- X win->core.dirtyconfig |= CWX;
- X }
- X if (win->core.y + (int) win->core.height < 0) {
- X win->core.y = dh + (win->core.y % dh);
- X win->core.dirtyconfig |= CWY;
- X }
- X else if (win->core.y >= dh) {
- X win->core.y = win->core.y % dh;
- X win->core.dirtyconfig |= CWY;
- X }
- X }
- X xwc.x = win->core.x;
- X xwc.y = win->core.y;
- X xwc.width = win->core.width;
- X xwc.height = win->core.height;
- X /* generic windows never change border or stacking */
- X ConfigureWindow(dpy,win,win->core.dirtyconfig,&xwc);
- X }
- X win->core.dirtyconfig &= ~(CWX|CWY|CWWidth|CWHeight);
- X}
- X
- X
- X/*
- X * WinAddColorClient
- X *
- X * Add cli to this win's list of colormap clients. Assumes that cli isn't
- X * already in the list.
- X */
- Xvoid
- XWinAddColorClient(win, cli)
- X WinGeneric *win;
- X Client *cli;
- X{
- X win->core.colormapClients = ListCons(cli, win->core.colormapClients);
- X}
- X
- X
- X/*
- X * WinRemoveColorClient
- X *
- X * Remove cli from this win's list of colormap clients. If there are no more
- X * clients, and this window is a WIN_COLORMAP, destroy the window. Assumes
- X * that cli appears in win's list zero or one times.
- X */
- Xvoid
- XWinRemoveColorClient(dpy, win, cli)
- X Display *dpy;
- X WinGeneric *win;
- X Client *cli;
- X{
- X List **l;
- X
- X l = &win->core.colormapClients;
- X while (*l != NULL) {
- X if ((*l)->value == cli) {
- X ListDestroyCell(l);
- X break;
- X }
- X l = &((*l)->next);
- X }
- X if (win->core.colormapClients == NULL_LIST
- X && win->core.kind == WIN_COLORMAP)
- X (WinFunc(win, core.destroyfunc))(dpy, win);
- X}
- END_OF_FILE
- if test 10853 -ne `wc -c <'win.c'`; then
- echo shar: \"'win.c'\" unpacked with wrong size!
- fi
- # end of 'win.c'
- fi
- if test -f 'win.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'win.h'\"
- else
- echo shar: Extracting \"'win.h'\" \(15691 characters\)
- sed "s/^X//" >'win.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ifndef _OLWM_WIN_H
- X#define _OLWM_WIN_H
- X
- X#ident "@(#)win.h 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)win.h 26.34 91/09/14 SMI"
- X *
- X */
- X
- X#include "list.h"
- X#include "events.h"
- X
- X/* Need this in screen.h */
- Xtypedef enum {
- X MENU_FULL, /* Close, Zoom, Props, Scale, Back, Refresh, Quit */
- X MENU_LIMITED, /* Dismiss, Scale, Refresh */
- X MENU_NONE,
- X MENU_ROOT, /* used only by usermenu.c */
- X MENU_VDM, /* used in virtual.c */
- X NUM_MENUS
- X} MenuIndex;
- X
- X#include "screen.h"
- X
- X#ifdef SHAPE
- X#include <X11/extensions/shape.h>
- X#endif
- X
- X/***************************************************************************
- X* Client state structures
- X***************************************************************************/
- X
- X/* a type for the four possible focus modes */
- Xtypedef enum { Passive, NoInput, LocallyActive, GloballyActive } FocusMode;
- X
- Xtypedef struct {
- X long flags;
- X MenuIndex menu_type;
- X int def_item; /* default menu item */
- X int pushpin_initial_state;
- X int cancel; /* 1 means Cancel instead of Dismiss */
- X /* numbers assigned as per OLXCI 3/20/89 */
- X} WMDecorations;
- X
- X/* pin states numbers, as per OLXCI 3/20/89 */
- X#define PIN_OUT 0
- X#define PIN_IN 1
- X
- X/* value for flags */
- X#define WMDecorationHeader (1L<<0)
- X#define WMDecorationFooter (1L<<1)
- X#define WMDecorationPushPin (1L<<2)
- X#define WMDecorationCloseButton (1L<<3)
- X#define WMDecorationHeaderDeco (WMDecorationPushPin | WMDecorationCloseButton)
- X#define WMDecorationResizeable (1L<<4)
- X#define WMDecorationIconName (1L<<5)
- X#define WMDecorationWarpToPin (1L<<6)
- X#define WMNoDecor (1L<<7)
- X
- Xtypedef int WMState; /* use state codes in Xutil.h */
- X
- Xtypedef struct { /* pointer warp state data */
- X int warpToX, warpToY; /* where to pointer goes on warp */
- X int dflButtonX, dflButtonY; /* location of default button */
- X int dflButtonW, dflButtonH; /* size of default button */
- X struct _client *warpBackClient; /* where to return focus */
- X int warpBackX, warpBackY; /* where to put it back */
- X} WarpInfo;
- X
- X/*
- X * Semantic window state
- X */
- Xtypedef struct _windowstate {
- X unsigned long flags;
- X unsigned long state;
- X} OLWindowState;
- X
- X/* value for OLWindowState flags */
- X#define WSSemanticState (1L<<0)
- X
- X/* value for OLWindowState state */
- X#define WSSemanticCompose (1L<<0)
- X#define WSSemanticCapsLock (1L<<1)
- X#define WSSemanticNumLock (1L<<2)
- X#define WSSemanticScrollLock (1L<<3)
- X
- X/* client flags */
- X#define CLOlwmOwned (1L<<0)
- X#define CLMoved (1L<<1)
- X
- X/***************************************************************************
- X* Client structures
- X***************************************************************************/
- X
- X/* a top-level client window */
- X
- Xtypedef struct _client
- X{
- X int flags;
- X WMDecorations *wmDecors;
- X WMState wmState;
- X XSizeHints *normHints; /* WM_NORMAL_HINTS */
- X XWMHints *wmHints; /* WM_HINTS */
- X char *wmInstance; /* WM_CLASS instance name */
- X char *wmClass; /* WM_CLASS class name */
- X int protocols;
- X FocusMode focusMode;
- X Bool isFocus;
- X Bool isSelected;
- X Bool isBusy;
- X Display *dpy;
- X int screen;
- X struct _winpaneframe *framewin;
- X struct _winiconframe *iconwin;
- X WarpInfo warpInfo;
- X Window groupid; /* Actually GroupID */
- X unsigned int groupmask; /* role that client is playing in group */
- X long busyState;
- X List *colormapWins;
- X struct _screeninfo *scrInfo;
- X OLWindowState *windowState;
- X Window transientFor;
- X#ifdef SHAPE
- X Bool isShaped;
- X#endif
- X/*
- X * Fields for the virtual window manager
- X */
- X int sticky;
- X} Client;
- X
- X#define ClientIsPinnable(cli) ((cli)->wmDecors->flags & WMDecorationPushPin)
- X
- X/***************************************************************************
- X* Window class structures
- X***************************************************************************/
- X
- X/* classes of window which we can deal with */
- Xtypedef enum { WIN_FRAME, WIN_ICON, WIN_RESIZE, WIN_PUSHPIN, WIN_WINBUTTON,
- X WIN_PANE, WIN_ICONPANE, WIN_COLORMAP, WIN_MENU, WIN_PINMENU,
- X WIN_NOFOCUS, WIN_ROOT, WIN_BUSY, WIN_VIRTUAL } WinKind;
- X
- Xtypedef int (*EvFunc)();
- Xtypedef int (*IntFunc)();
- Xtypedef struct _genericclasscore {
- X WinKind kind;
- X EvFunc xevents[LASTEvent]; /* function for each X event */
- X EvFunc extEventHdlr; /* handler for extension events */
- X EvFunc focusfunc; /* focus state has changed */
- X EvFunc drawfunc; /* draw window */
- X EvFunc destroyfunc; /* destroy window and structures */
- X EvFunc selectfunc; /* selecte state has changed */
- X EvFunc newconfigfunc; /* compute configuration */
- X EvFunc newposfunc; /* set position */
- X EvFunc setconfigfunc; /* set configuration */
- X EvFunc createcallback; /* used in menu creation */
- X IntFunc heightfunc; /* compute correct height */
- X IntFunc widthfunc; /* compute correct width */
- X} GenericClassCore;
- X
- Xtypedef struct _classgeneric {
- X GenericClassCore core;
- X} ClassGeneric;
- X
- Xtypedef struct _genericframeclasscore {
- X IntFunc heighttop, heightbottom, widthleft, widthright;
- X IntFunc menuPress;
- X IntFunc adjustPress, adjustClick;
- X IntFunc selectPress, selectClick, selectDoubleClick, selectDrag;
- X IntFunc fullrestoreToggle;
- X} GenericFrameClassCore;
- X
- Xtypedef struct _classgenericframe {
- X GenericClassCore core;
- X GenericFrameClassCore fcore;
- X} ClassGenericFrame;
- X
- Xtypedef struct _genericpaneclasscore {
- X EvFunc setsizefunc;
- X} GenericPaneClassCore;
- X
- Xtypedef struct _classpane {
- X GenericClassCore core;
- X GenericPaneClassCore pcore;
- X} ClassGenericPane;
- X
- Xtypedef struct _classvirtual {
- X GenericClassCore core;
- X GenericPaneClassCore pcore;
- X} ClassVirtualPane;
- X
- Xtypedef ClassGenericFrame ClassPaneFrame;
- Xtypedef ClassGenericFrame ClassIconFrame;
- Xtypedef ClassGeneric ClassPushPin;
- Xtypedef ClassGenericPane ClassPane;
- Xtypedef ClassGeneric ClassMenu;
- Xtypedef ClassGenericPane ClassPinMenu;
- Xtypedef ClassGeneric ClassResize;
- Xtypedef ClassGeneric ClassButton;
- Xtypedef ClassGeneric ClassBusy;
- Xtypedef ClassGenericPane ClassIconPane;
- Xtypedef ClassGeneric ClassRoot;
- Xtypedef ClassGeneric ClassNoFocus;
- Xtypedef ClassGeneric ClassColormap;
- X
- X/* Core functions:
- X *
- X * destroyfunc - int (*destroyfunc)(Display *dpy, WinGeneric *win)
- X * Called when the window is being destroyed; should destroy any private
- X * resources associated with the window (including possibly destroying
- X * the X window) and destroy the window information structure.
- X *
- X * selectfunc - int (*selectfunc)(Display *dpy, WinGeneric *win, Bool selected)
- X * Called whenever the window is selected/deselected. The window should
- X * update its private state -- most particularly, its screen appearance --
- X * to match the new state. This function is only called when the selection
- X * state has changed.
- X *
- X * focusfunc - int (*focusfunc)(Display *dpy, WinGeneric *win, Bool focus)
- X * Called whenever the window gains/loses focus. The window should update
- X * its private state -- most particularly, its screen appearance --
- X * to match the new state. The window does _not_ need to take focus if
- X * it is active; this has already been taken care of. This function is
- X * only called when the focus has changed.
- X *
- X * newconfigfunc - int (*newconfigfunc)(WinGeneric *win,
- X * XConfigureRequestEvent *xcre)
- X * Called when the configuration of a window should be recomputed. It
- X * can be assumed that all child windows will have already computed their
- X * sizes. This function should compute the size of this window, and call
- X * the newposfunc of each child that needs to be moved. If the configuration
- X * of the window is changed by this function, the dirtyconfig flag should be
- X * set. The xcre parameter will be be set to a configure request event
- X * structure only if a configure request was received for this
- X * particular window; otherwise the parameter will be null.
- X * Returns True if any dirtyconfig flag has been set.
- X *
- X * newposfunc - int (*newposfunc)(WinGeneric *win, int x, y)
- X * Instructs a child window to move to a position (x,y). If this position
- X * is different from the old position, then the dirtyconfig flag
- X * should be set. Returns True if any dirtyconfig flag has been set.
- X *
- X * setconfigfunc - int (*setconfigfunc)(Display *dpy, WinGeneric *win)
- X * The window's configuration may have changed; if so, call XConfigureWindow
- X * to make the changes. Clear the dirtyconfig bits in the process.
- X * The pane window will need to send a synthetic configure notify for
- X * any configuration call.
- X *
- X * createcallback - int (*createcallback)(WinGeneric *self, Client *cli,
- X * WinGeneric *parent)
- X * For internally-created panes, the client and parent are filled out
- X * when the StateNew process would normally create a pane.
- X *
- X * heightfunc - int (*heightfunc)(WinGeneric *self, XConfigureRequestEvent *pxcre)
- X * should return the window's correct height, given a configure request
- X * event and the current environment. Used to see if a window needs to
- X * be resized.
- X *
- X * widthfunc - same as heightfunc, except that it returns correct width
- X */
- X
- X/***************************************************************************
- X* Window instance structures
- X***************************************************************************/
- X
- X/*
- X * The wincore structure contains common information about each window.
- X *
- X * stack_mode, stack_sib, and dirtyconfig contain information pending window
- X * configuration changes that have not yet been sent to the server.
- X *
- X * exposures is a list of exposed rectangles that have not yet been repainted.
- X *
- X * colormapClients is a list of clients that have this window in their
- X * colormapWins list. tag is used only while processing changes to a client's
- X * colormapWins list.
- X */
- Xtypedef struct _wincore {
- X Window self;
- X WinKind kind;
- X struct _wingeneric *parent;
- X List *children;
- X Client *client;
- X int x, y;
- X unsigned int width, height;
- X int stack_mode;
- X Window stack_sib;
- X unsigned int dirtyconfig;
- X Colormap colormap;
- X List *exposures;
- X List *colormapClients;
- X Bool tag;
- X char *helpstring;
- X/*
- X * For the virtual window manager
- X */
- X Window virtual;
- X} WinCore;
- X/* REMIND maybe add: cursor */
- X
- X/* macros associated with a window core */
- X#define WinIsKind(w,k) ((w)->core.kind == (k))
- X#define WinClass(w) ((w)->class)
- X#define WinFunc(w,f) ((w)->class->f)
- X#define WinScreen(w) ((w)->core.client->screen);
- X#define WinRootID(w) ((w)->core.client->scrInfo->rootid)
- X#define WinDepth(w) ((w)->core.client->scrInfo->depth)
- X#define WinVisual(w) ((w)->core.client->scrInfo->visual)
- X#define WinGI(w,idx) ((w)->core.client->scrInfo->gi[(idx)])
- X#define WinGC(w,idx) ((w)->core.client->scrInfo->gc[(idx)])
- X#define Win3D(w) ((w)->core.client->scrInfo->use3D)
- X
- X/*
- X * These macros access the fields of the ColorMapFocus struct inside
- X * the ScreenInfo struct of a Client.
- X */
- X#define ColorFocusWindow(win) ((win)->core.client->scrInfo->cmapfocus.window)
- X#define ColorFocusClient(win) ((win)->core.client->scrInfo->cmapfocus.client)
- X#define ColorFocusLocked(win) ((win)->core.client->scrInfo->cmapfocus.locked)
- X
- X
- X/* FrameCore defines fields common to all types of frame */
- Xtypedef struct _winframecore {
- X struct _wingenericpane *panewin;/* pane inside frame */
- X char *name; /* name to be displayed on frame */
- X Bool fullsize; /* if frame is full size */
- X} WinFrameCore;
- X
- X/* PaneCore defines fields common to all types of panes */
- Xtypedef struct _winpanecore {
- X int oldBorderWidth;
- X int oldSaveUnder;
- X int pendingUnmaps;
- X} WinPaneCore;
- X
- X/* Specific window types */
- X
- Xtypedef struct _wingeneric {
- X ClassGeneric *class;
- X WinCore core;
- X} WinGeneric;
- X
- Xtypedef struct _winroot {
- X ClassGeneric *class;
- X WinCore core;
- X SemanticAction currentAction;
- X XEvent buttonPressEvent;
- X} WinRoot;
- X
- Xtypedef struct _wingenericframe {
- X ClassGenericFrame *class;
- X WinCore core;
- X WinFrameCore fcore;
- X} WinGenericFrame;
- X
- X/* macros for generic frames */
- X#define FrameHeightTop(w) (WinFunc((w),fcore.heighttop))((w))
- X#define FrameHeightBottom(w) (WinFunc((w),fcore.heightbottom))((w))
- X#define FrameWidthLeft(w) (WinFunc((w),fcore.widthleft))((w))
- X#define FrameWidthRight(w) (WinFunc((w),fcore.widthright))((w))
- X
- X
- Xtypedef struct _wingenericpane {
- X ClassGenericPane *class;
- X WinCore core;
- X WinPaneCore pcore;
- X} WinGenericPane;
- X
- Xtypedef struct {
- X char *string;
- X int length,width;
- X} Footer;
- X
- Xtypedef struct _winpaneframe {
- X ClassPaneFrame *class;
- X WinCore core;
- X WinFrameCore fcore;
- X
- X /* resize corners */
- X struct _winresize *resizeCorner[4];
- X
- X /* footers */
- X Footer leftFooter;
- X Footer rightFooter;
- X
- X /* title fields */
- X int titleOff; /* x offset of title area in pix */
- X int nameLength; /* length of name in chars */
- X int nameWidth; /* width of name in pix */
- X int titlex, titley; /* title position */
- X
- X /* pointer warp status */
- X Bool pointerIsWarped;
- X
- X /* sizing functions */
- X void (*normfullsizefunc)(); /* normal/full size function */
- X Bool restoreSet; /* True => restore values valid */
- X int restoreX, restoreY,
- X restoreWidth, restoreHeight;
- X /* context for full/norm size
- X * note that x/y is frame; w/h are pane
- X */
- X
- X /* other decorations */
- X WinGeneric *winDeco; /* window button or pushpin */
- X struct _winbusy *winBusy; /* special window when busy */
- X} WinPaneFrame;
- X
- Xtypedef struct _winiconframe {
- X ClassIconFrame *class;
- X WinCore core;
- X WinFrameCore fcore;
- X struct _iconSlot *iconslot;
- X Bool fManuallyPositioned;
- X int nameX, nameY; /* name of icon */
- X int nameWidth;
- X int nameLength;
- X} WinIconFrame;
- X
- Xtypedef struct _winiconpane {
- X ClassIconPane *class;
- X WinCore core;
- X WinPaneCore pcore;
- X Bool iconClientWindow; /* true iff client owns pane */
- X Pixmap iconPixmap; /* None if icon has client window */
- X Pixmap iconMask;
- X} WinIconPane;
- X
- X/* icon border sizes, in pixels */
- X#define ICON_HORZBORDER 3
- X#define ICON_VERTBORDER 3
- X
- Xtypedef struct _winpushpin {
- X ClassPushPin *class;
- X WinCore core;
- X Bool pushpinin;
- X} WinPushPin;
- X
- Xtypedef struct _winpane {
- X ClassPane *class;
- X WinCore core;
- X WinPaneCore pcore;
- X} WinPane;
- X
- Xtypedef struct _winmenu {
- X ClassMenu *class;
- X WinCore core;
- X struct _menuInfo *menuInfo;
- X Bool ignoreNextExpose;
- X} WinMenu;
- X
- Xtypedef struct _winpinmenu { /* pinned menus are a subclass of panes */
- X ClassPinMenu *class;
- X WinCore core;
- X WinPaneCore pcore;
- X struct _menuInfo *menuInfo;
- X} WinPinMenu;
- X
- Xtypedef struct _winvirtual {
- X ClassVirtualPane *class;
- X WinCore core;
- X} WinVirtual;
- X
- Xtypedef enum {upleft, upright, lowleft, lowright, keyevent} WhichResize;
- X
- Xtypedef struct _winresize {
- X ClassResize *class;
- X WinCore core;
- X WhichResize which;
- X Bool depressed;
- X} WinResize;
- X
- Xtypedef struct _winbutton {
- X ClassButton *class;
- X WinCore core;
- X} WinButton;
- X
- Xtypedef struct _winbusy {
- X ClassBusy *class;
- X WinCore core;
- X Bool isFocus;
- X} WinBusy;
- X
- Xtypedef WinGeneric WinNoFocus;
- X
- X/* colormap windows aren't linked into the ordinary window tree since they
- X * are presumed under client control. We create info structures for them
- X * only so appropriate events can be dispatched on them. Colormap windows
- X * are in a list on the client structure.
- X */
- Xtypedef WinGeneric WinColormap;
- X
- X/* functions mapping windows to infos */
- X
- Xextern void WIInstallInfo();
- Xextern Bool WIUninstallInfo();
- Xextern WinGeneric *WIGetInfo();
- Xextern WinGeneric *VGetInfo();
- Xextern void WIApply();
- X
- X/* window functions */
- Xextern void WinAddChild();
- Xextern void WinRemoveChild();
- X
- X/* Useful client macros */
- X#define PANEOFCLIENT(cli) ((cli)->framewin->fcore.panewin)
- X#define PANEWINOFCLIENT(cli) (PANEOFCLIENT(cli)->core.self)
- X
- X/* globals */
- X#ifdef SHAPE
- Xextern Bool ShapeSupported;
- Xextern int ShapeEventBase;
- Xextern int ShapeErrorBase;
- X#endif
- X
- X#endif /* _OLWM_WIN_H */
- END_OF_FILE
- if test 15691 -ne `wc -c <'win.h'`; then
- echo shar: \"'win.h'\" unpacked with wrong size!
- fi
- # end of 'win.h'
- fi
- if test -f 'winbutton.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'winbutton.c'\"
- else
- echo shar: Extracting \"'winbutton.c'\" \(10312 characters\)
- sed "s/^X//" >'winbutton.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989, 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)winbutton.c 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)winbutton.c 26.22 91/09/14 SMI"
- X *
- X */
- X
- X#include <errno.h>
- X#include <stdio.h>
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include <X11/Xatom.h>
- X#include <olgx/olgx.h>
- X
- X#include "i18n.h"
- X#include "ollocale.h"
- X#include "mem.h"
- X#include "olwm.h"
- X#include "win.h"
- X#include "globals.h"
- X#include "menu.h"
- X#include "events.h"
- X
- Xextern void FrameAllowEvents();
- Xextern Bool DoDefaultMenuAction();
- X
- X/***************************************************************************
- X* private data
- X***************************************************************************/
- X
- X#define in_windowmark(win,x,y) \
- X ( (x) >= 0 && (y) >= 0 && \
- X (x) <= Abbrev_MenuButton_Width(WinGI((win),NORMAL_GINFO)) && \
- X (y) <= Abbrev_MenuButton_Height(WinGI((win),NORMAL_GINFO)) \
- X )
- Xstatic Bool buttonActive = False;
- Xstatic ClassButton classButton;
- Xstatic SemanticAction currentAction = ACTION_NONE;
- X
- X/***************************************************************************
- X* private functions
- X***************************************************************************/
- X
- Xstatic int drawButton();
- X
- Xstatic void
- XdoUnhilite(act, mode, winInfo)
- X int act;
- X MenuTrackMode mode;
- X WinButton *winInfo;
- X{
- X Graphics_info *gisNormal = WinGI(winInfo, NORMAL_GINFO);
- X long flags;
- X
- X if (act != SYNC_CHANGECLICK)
- X flags = OLGX_NORMAL | OLGX_ERASE;
- X else if (mode == MODE_CLICK)
- X flags = OLGX_BUSY | OLGX_ERASE | OLGX_NORMAL;
- X else {
- X /* don't do this; it's unsettling to press it in when you drag again */
- X return;
- X }
- X
- X olgx_draw_abbrev_button(gisNormal, winInfo->core.self, 0, 0, flags);
- X}
- X
- X/*
- X * eventButtonPress - handle button press events on the close button window.
- X */
- Xstatic int
- XeventButtonPress(dpy, event, winInfo)
- XDisplay *dpy;
- XXEvent *event;
- XWinButton *winInfo;
- X{
- X Client *cli = winInfo->core.client;
- X WinPaneFrame *winFrame = cli->framewin;
- X SemanticAction a;
- X Graphics_info *gis;
- X
- X if (cli->isFocus)
- X gis = WinGI(winInfo, INPUTFOCUS_GINFO);
- X else gis = WinGI(winInfo,NORMAL_GINFO);
- X
- X a = ResolveMouseBinding(dpy, event, ModMaskMap[MOD_CONSTRAIN]);
- X
- X switch (a) {
- X case ACTION_SELECT:
- X olgx_draw_abbrev_button(gis, winInfo->core.self,
- X 0, 0, OLGX_INVOKED);
- X /*
- X * REMIND: bad style. This is grabbing the pointer after
- X * the fact. We should set up a passive grab instead.
- X */
- X XGrabPointer(dpy, winInfo->core.self, False,
- X (ButtonReleaseMask | ButtonPressMask | PointerMotionMask),
- X GrabModeAsync, GrabModeAsync, None,
- X GRV.MovePointer, CurrentTime);
- X buttonActive = True;
- X currentAction = a;
- X break;
- X
- X case ACTION_MENU:
- X olgx_draw_abbrev_button(gis, winInfo->core.self,
- X 0, 0, OLGX_INVOKED);
- X if (winFrame->core.client->wmDecors->menu_type != MENU_NONE)
- X ShowStandardMenuSync(winFrame, event, True, doUnhilite, winInfo);
- X return;
- X
- X default:
- X FrameAllowEvents(cli, event->xbutton.time);
- X return;
- X }
- X}
- X
- X/*
- X * eventButtonRelease - handle button release events on the close button window.
- X */
- Xstatic int
- XeventButtonRelease(dpy, event, winInfo)
- XDisplay *dpy;
- XXEvent *event;
- XWinButton *winInfo;
- X{
- X Client *cli = winInfo->core.client;
- X int x,y;
- X
- X FrameAllowEvents(cli, event->xbutton.time);
- X
- X if (!AllButtonsUp(event))
- X return;
- X
- X XUngrabPointer(dpy, CurrentTime);
- X
- X x = event->xbutton.x;
- X y = event->xbutton.y;
- X
- X if (buttonActive) {
- X drawButton(dpy, winInfo);
- X buttonActive = False;
- X }
- X
- X if (!in_windowmark(winInfo,x,y) || currentAction != ACTION_SELECT) {
- X return;
- X }
- X
- X if (!DoDefaultMenuAction(winInfo)) {
- X StateNormIcon(cli);
- X }
- X
- X currentAction = ACTION_NONE;
- X}
- X
- X/*
- X * eventMotionNotify - handle motion notify events on the close button window.
- X */
- Xstatic int
- XeventMotionNotify(dpy, event, winInfo)
- XDisplay *dpy;
- XXEvent *event;
- XWinButton *winInfo;
- X{
- X int x,y;
- X Client *cli = winInfo->core.client;
- X Graphics_info *gis;
- X
- X if (cli->isFocus)
- X gis = WinGI(winInfo, INPUTFOCUS_GINFO);
- X else gis == WinGI(winInfo,NORMAL_GINFO);
- X
- X if (!event->xmotion.same_screen || currentAction != ACTION_SELECT)
- X return;
- X
- X x = event->xmotion.x;
- X y = event->xmotion.y;
- X if ( buttonActive && !in_windowmark(winInfo,x,y) ) {
- X drawButton(dpy, winInfo);
- X buttonActive = False;
- X } else if ( !buttonActive && in_windowmark(winInfo,x,y) ) {
- X olgx_draw_abbrev_button(gis, winInfo->core.self,
- X 0, 0, OLGX_INVOKED);
- X buttonActive = True;
- X }
- X}
- X
- X/*
- X * drawButton -- draw the window button
- X */
- X/*ARGSUSED*/
- Xstatic int
- XdrawButton(dpy, winInfo)
- XDisplay *dpy;
- XWinButton *winInfo;
- X{
- X Client *cli = winInfo->core.client;
- X GC windowGC = WinGC(winInfo,WINDOW_GC);
- X XGCValues gcv;
- X int focusLines = (GRV.FocusFollowsMouse ? 1 : 0) ^
- X (GRV.InvertFocusHighlighting ? 1 : 0);
- X Graphics_info *gis;
- X
- X if (cli->isFocus)
- X gis = WinGI(winInfo, INPUTFOCUS_GINFO);
- X else gis = WinGI(winInfo,NORMAL_GINFO);
- X
- X /*
- X * Erase the background first. Unfortunately, we can't depend on
- X * OLGX_ERASE to do the right thing, because it (a) erases only in BG1,
- X * and (b) erases only in 2D mode. We need to erase a background color
- X * that depends on the state of the frame. If we're in click-focus and we
- X * have the focus, draw in BG2; otherwise, draw in BG1.
- X */
- X
- X /* Temporarily set background to BG2 if click-to-type */
- X if (!focusLines && winInfo->core.client->isFocus && Win3D(winInfo)) {
- X XGetGCValues(dpy,windowGC,GCBackground,&gcv);
- X XSetBackground(dpy,windowGC,cli->scrInfo->colorInfo.bg2Color);
- X }
- X
- X XFillRectangle(dpy, winInfo->core.self, windowGC, 0, 0,
- X Abbrev_MenuButton_Width(gis),
- X Abbrev_MenuButton_Height(gis));
- X
- X /* Restore background back to BG1 */
- X if (!focusLines && winInfo->core.client->isFocus && Win3D(winInfo)) {
- X XSetBackground(dpy,windowGC,gcv.background);
- X }
- X
- X olgx_draw_abbrev_button(gis, winInfo->core.self,
- X 0, 0, OLGX_NORMAL | OLGX_ERASE);
- X
- X /*
- X * REMIND: hack for working around OLGX deficiency. OLGX erases the
- X * "ears" at each corner of the window button to the background color.
- X * They should really be filled in with the foreground color.
- X */
- X if (!focusLines && winInfo->core.client->isFocus && !Win3D(winInfo)) {
- X XDrawRectangle(dpy, winInfo->core.self, WinGC(winInfo,FOREGROUND_GC),
- X 0, 0,
- X Abbrev_MenuButton_Width(gis)-1,
- X Abbrev_MenuButton_Height(gis)-1);
- X XDrawPoint(dpy, winInfo->core.self, WinGC(winInfo,FOREGROUND_GC),
- X Abbrev_MenuButton_Width(gis)-1,
- X Abbrev_MenuButton_Height(gis)-1);
- X }
- X
- X}
- X
- X
- X/*
- X * DestroyButton -- destroy the close button window resources and free any allocated
- X * data.
- X */
- Xstatic int
- XdestroyButton(dpy, winInfo)
- XDisplay *dpy;
- XWinButton *winInfo;
- X{
- X /* free our data and throw away window */
- X DestroyWindow(winInfo);
- X MemFree(winInfo);
- X}
- X
- X/*
- X * focusButton - the focus or selection state has changed
- X */
- Xstatic int
- XfocusButton(dpy, winInfo, selected)
- XDisplay *dpy;
- XWinButton *winInfo;
- XBool selected;
- X{
- X (WinFunc(winInfo,core.drawfunc))(dpy, winInfo);
- X}
- X
- X/*
- X * heightfuncButton - recomputes the height of the close button window
- X */
- Xstatic int
- XheightfuncButton(win, pxcre)
- XWinButton *win;
- XXConfigureRequestEvent *pxcre;
- X{
- X return Abbrev_MenuButton_Width(WinGI(win,NORMAL_GINFO));
- X}
- X
- X/*
- X * widthfuncButton - recomputes the width of the close button window
- X */
- Xstatic int
- XwidthfuncButton(win, pxcre)
- XWinButton *win;
- XXConfigureRequestEvent *pxcre;
- X{
- X return Abbrev_MenuButton_Height(WinGI(win,NORMAL_GINFO));
- X}
- X
- X
- X/***************************************************************************
- X* global functions
- X***************************************************************************/
- X
- X/*
- X * MakeButton -- create the close button window. Return a WinGeneric structure.
- X */
- XWinButton *
- XMakeButton(dpy, par, x, y)
- XDisplay *dpy;
- XWinGeneric *par;
- Xint x,y;
- X{
- X WinButton *w;
- X Window win;
- X unsigned long valuemask;
- X XSetWindowAttributes attributes;
- X Graphics_info *gisNormal = WinGI(par,NORMAL_GINFO);
- X
- X attributes.event_mask =
- X ButtonReleaseMask | ButtonPressMask | ExposureMask;
- X attributes.cursor = GRV.IconPointer;
- X valuemask = CWEventMask | CWCursor;
- X
- X win = XCreateWindow(dpy, par->core.self,
- X x, y,
- X Abbrev_MenuButton_Width(gisNormal),
- X Abbrev_MenuButton_Height(gisNormal),
- X 0,
- X CopyFromParent,
- X CopyFromParent,
- X CopyFromParent,
- X valuemask,
- X &attributes);
- X
- X /* create the associated structure */
- X w = MemNew(WinButton);
- X w->core.self = win;
- X w->class = &classButton;
- X w->core.kind = WIN_WINBUTTON;
- X WinAddChild(par,w);
- X w->core.children = NULL;
- X w->core.client = par->core.client;
- X w->core.x = x;
- X w->core.y = y;
- X w->core.width = Abbrev_MenuButton_Width(gisNormal);
- X w->core.height = Abbrev_MenuButton_Height(gisNormal);
- X w->core.dirtyconfig = 0;
- X w->core.exposures = NULL;
- X w->core.helpstring = "olwm:CloseButton";
- X
- X /* register the window */
- X WIInstallInfo(w);
- X
- X MapWindow(w);
- X
- X return w;
- X}
- X
- Xvoid
- XButtonInit(dpy)
- XDisplay *dpy;
- X{
- X classButton.core.kind = WIN_WINBUTTON;
- X classButton.core.xevents[ButtonPress] = eventButtonPress;
- X classButton.core.xevents[ButtonRelease] = eventButtonRelease;
- X classButton.core.xevents[MotionNotify] = eventMotionNotify;
- X classButton.core.xevents[Expose] = WinEventExpose;
- X classButton.core.focusfunc = focusButton;
- X classButton.core.drawfunc = drawButton;
- X classButton.core.destroyfunc = destroyButton;
- X classButton.core.selectfunc = NULL;
- X classButton.core.newconfigfunc = WinNewConfigFunc;
- X classButton.core.newposfunc = WinNewPosFunc;
- X classButton.core.setconfigfunc = WinSetConfigFunc;
- X classButton.core.createcallback = NULL;
- X classButton.core.heightfunc = heightfuncButton;
- X classButton.core.widthfunc = widthfuncButton;
- X}
- X
- END_OF_FILE
- if test 10312 -ne `wc -c <'winbutton.c'`; then
- echo shar: \"'winbutton.c'\" unpacked with wrong size!
- fi
- # end of 'winbutton.c'
- fi
- echo shar: End of archive 17 \(of 21\).
- cp /dev/null ark17isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 21 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Molecular Simulations, Inc. mail: dcmartin@postgres.berkeley.edu
- 796 N. Pastoria Avenue uucp: uwvax!ucbvax!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-